home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 April / macformat-049.iso / mac / Shareware Plus / Developers / dropg++ / usr / include / sys / device.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  5.8 KB  |  144 lines  |  [TEXT/R*ch]

  1. /*
  2.  * Copyright (c) 1992, 1993
  3.  *    The Regents of the University of California.  All rights reserved.
  4.  *
  5.  * This software was developed by the Computer Systems Engineering group
  6.  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
  7.  * contributed to Berkeley.
  8.  *
  9.  * All advertising materials mentioning features or use of this software
  10.  * must display the following acknowledgement:
  11.  *    This product includes software developed by the University of
  12.  *    California, Lawrence Berkeley Laboratory.
  13.  *
  14.  * Redistribution and use in source and binary forms, with or without
  15.  * modification, are permitted provided that the following conditions
  16.  * are met:
  17.  * 1. Redistributions of source code must retain the above copyright
  18.  *    notice, this list of conditions and the following disclaimer.
  19.  * 2. Redistributions in binary form must reproduce the above copyright
  20.  *    notice, this list of conditions and the following disclaimer in the
  21.  *    documentation and/or other materials provided with the distribution.
  22.  * 3. All advertising materials mentioning features or use of this software
  23.  *    must display the following acknowledgement:
  24.  *    This product includes software developed by the University of
  25.  *    California, Berkeley and its contributors.
  26.  * 4. Neither the name of the University nor the names of its contributors
  27.  *    may be used to endorse or promote products derived from this software
  28.  *    without specific prior written permission.
  29.  *
  30.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  31.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  32.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  33.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  34.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  38.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  39.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  40.  * SUCH DAMAGE.
  41.  *
  42.  *    @(#)device.h    8.2 (Berkeley) 2/17/94
  43.  */
  44.  
  45. #ifndef _SYS_DEVICE_H_
  46. #define    _SYS_DEVICE_H_
  47.  
  48. /*
  49.  * Minimal device structures.
  50.  * Note that all ``system'' device types are listed here.
  51.  */
  52. enum devclass {
  53.     DV_DULL,        /* generic, no special info */
  54.     DV_CPU,            /* CPU (carries resource utilization) */
  55.     DV_DISK,        /* disk drive (label, etc) */
  56.     DV_IFNET,        /* network interface */
  57.     DV_TAPE,        /* tape device */
  58.     DV_TTY            /* serial line interface (???) */
  59. };
  60.  
  61. struct device {
  62.     enum    devclass dv_class;    /* this device's classification */
  63.     struct    device *dv_next;    /* next in list of all */
  64.     struct    cfdata *dv_cfdata;    /* config data that found us */
  65.     int    dv_unit;        /* device unit number */
  66.     char    dv_xname[16];        /* external name (name + unit) */
  67.     struct    device *dv_parent;    /* pointer to parent device */
  68. };
  69.  
  70. /* `event' counters (use zero or more per device instance, as needed) */
  71. struct evcnt {
  72.     struct    evcnt *ev_next;        /* linked list */
  73.     struct    device *ev_dev;        /* associated device */
  74.     int    ev_count;        /* how many have occurred */
  75.     char    ev_name[8];        /* what to call them (systat display) */
  76. };
  77.  
  78. /*
  79.  * Configuration data (i.e., data placed in ioconf.c).
  80.  */
  81. struct cfdata {
  82.     struct    cfdriver *cf_driver;    /* config driver */
  83.     short    cf_unit;        /* unit number */
  84.     short    cf_fstate;        /* finding state (below) */
  85.     int    *cf_loc;        /* locators (machine dependent) */
  86.     int    cf_flags;        /* flags from config */
  87.     short    *cf_parents;        /* potential parents */
  88.     void    (**cf_ivstubs)();    /* config-generated vectors, if any */
  89. };
  90. #define FSTATE_NOTFOUND    0    /* has not been found */
  91. #define    FSTATE_FOUND    1    /* has been found */
  92. #define    FSTATE_STAR    2    /* duplicable */
  93.  
  94. typedef int (*cfmatch_t) __P((struct device *, struct cfdata *, void *));
  95.  
  96. /*
  97.  * `configuration' driver (what the machine-independent autoconf uses).
  98.  * As devices are found, they are applied against all the potential matches.
  99.  * The one with the best match is taken, and a device structure (plus any
  100.  * other data desired) is allocated.  Pointers to these are placed into
  101.  * an array of pointers.  The array itself must be dynamic since devices
  102.  * can be found long after the machine is up and running.
  103.  */
  104. struct cfdriver {
  105.     void    **cd_devs;        /* devices found */
  106.     char    *cd_name;        /* device name */
  107.     cfmatch_t cd_match;        /* returns a match level */
  108.     void    (*cd_attach) __P((struct device *, struct device *, void *));
  109.     enum    devclass cd_class;    /* device classification */
  110.     size_t    cd_devsize;        /* size of dev data (for malloc) */
  111.     void    *cd_aux;        /* additional driver, if any */
  112.     int    cd_ndevs;        /* size of cd_devs array */
  113. };
  114.  
  115. /*
  116.  * Configuration printing functions, and their return codes.  The second
  117.  * argument is NULL if the device was configured; otherwise it is the name
  118.  * of the parent device.  The return value is ignored if the device was
  119.  * configured, so most functions can return UNCONF unconditionally.
  120.  */
  121. typedef int (*cfprint_t) __P((void *, char *));
  122. #define    QUIET    0        /* print nothing */
  123. #define    UNCONF    1        /* print " not configured\n" */
  124. #define    UNSUPP    2        /* print " not supported\n" */
  125.  
  126. /*
  127.  * Pseudo-device attach information (function + number of pseudo-devs).
  128.  */
  129. struct pdevinit {
  130.     void    (*pdev_attach) __P((int));
  131.     int    pdev_count;
  132. };
  133.  
  134. struct    device *alldevs;    /* head of list of all devices */
  135. struct    evcnt *allevents;    /* head of list of all events */
  136.  
  137. struct cfdata *config_search __P((cfmatch_t, struct device *, void *));
  138. struct cfdata *config_rootsearch __P((cfmatch_t, char *, void *));
  139. int config_found __P((struct device *, void *, cfprint_t));
  140. int config_rootfound __P((char *, void *));
  141. void config_attach __P((struct device *, struct cfdata *, void *, cfprint_t));
  142. void evcnt_attach __P((struct device *, const char *, struct evcnt *));
  143. #endif /* !_SYS_DEVICE_H_ */
  144.